cc.Class({
    extends: cc.Component,
    properties: {
       title:cc.Label,
       showSprite:cc.Sprite,
       showSpriteFrame:[cc.SpriteFrame],
       coinBtn:cc.Node,
       adsBtn:cc.Node,
       coin:cc.Label,
        back:cc.Node
    },
    // use this for initialization
    onLoad: function () {
      this.titleLabel = ['COOKING QUICK','DRINK QUICK','DOUBLE DIAMOND'];
      this.coinLabel = [50,50,50];
      this.btnEven();
    },
    btnEven(){
        this.coinBtn.on('click',function(){
            if(this.select) return;
            this.select = true;
            if(this.typeNum === 0){
                cc.find('Canvas').emit('speedMeat');
                cc.speedMeat = 2;
            }else if(this.typeNum === 1){
                cc.find('Canvas').emit('speedDrink');
                cc.speedDrink = 2;
            }else{
                cc.find('Canvas').emit('doubleDiamond');
                cc.doubleDiamond = 2;
            }
            cc.configData.money =  cc.configData.money - this.coinLabel[this.typeNum];
            cc.sys.localStorage.setItem("money",cc.configData.money);
            if(CC_JSB){
                this.node.active = false;
                cc.find('Canvas').emit('money');
            }else{
                cc.sdkbox.setDataAsync(cc.configData,function(){
                    console.log('存储成功',cc.configData);
                    cc.find('Canvas').emit('money');
                    this.node.active = false;
                }.bind(this));
            }
        },this);
        this.adsBtn.on('click',function(){
            if(this.select) return;
            this.select = true;


        },this);
        this.back.on('click',function(){
         this.node.active = false;
        },this);
    },
    init(num){
     this.select = false;
     this.typeNum = num;
     this.title.string = this.titleLabel[num];
     this.coin.string = this.coinLabel[num];
     this.showSprite.spriteFrame = this.showSpriteFrame[num];
     if(cc.configData.money < this.coinLabel[num]){
         this.coinBtn.active = false;
     }else{
         this.coinBtn.active = true;
     }
    },
    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {
    // },
});
